home *** CD-ROM | disk | FTP | other *** search
- Path: news.gate.net!pslfl2-35
- From: bhutto@gate.net (William Hutto)
- Newsgroups: comp.lang.c
- Subject: Re: cpp question
- Date: 21 Jan 1996 13:28:15 GMT
- Organization: CyberGate, Inc.
- Message-ID: <4dtf1f$21r4@news.gate.net>
- References: <4drm99$j0m@peabody.colorado.edu>
- NNTP-Posting-Host: pslfl2-35.gate.net
- X-Newsreader: News Xpress Version 1.0 Beta #4
-
- In article <4drm99$j0m@peabody.colorado.edu>,
- woodjr@rintintin.Colorado.EDU (WOOD JAMEY RYAN) spake:
- ;I have something like this:
- ;
- ; #define USERLEN 8
- ; #define HOSTLEN 15
- ;
- ; char name[] = "woodjr";
- ; char host[] = "really.long.hostname.com";
- ; char s[100];
- ;
- ; sprintf(s, "%.USERLENs@%.HOSTLENs", name, host);
- ;
- ;And I want cpp to parse the sprintf line to:
- ;
- ; sprintf(s, "%.8s@%.15s", name, host);
- ;
- ;Which it (of course) isn't doing. Is there some syntax I
- ;can use to get it to do this?
-
- There shur is:
-
- sprintf(s, "%.*s@%.*s", USERLEN, name, HOSTLEN, host);
-
- The asterisk in the width.precision fields in the formatting sequence allows
- you to include the size as an integer value in your parameter list.
-
- Bill
-
- "Whatcha got on?...Your mind?"
-